
/**
 * 获取goodsType全称
 如：```
                     {
                        "children": [],
                        "code": null,
                        "fileIdOfImg": null,
                        "gmtCreate": 1698593928567,
                        "gmtModified": 1698593928567,
                        "id": 477010030927877,
                        "name": "条形码扫描",
                        "parent": {
                            "children": null,
                            "code": "6975239287826",
                            "fileIdOfImg": 477009362071557,
                            "gmtCreate": 1698593767486,
                            "gmtModified": 1698593767486,
                            "id": 477009371213829,
                            "name": "扫描机",
                            "parent": null,
                            "parentId": null
                        },
                        "parentId": 477009371213829
                    }
```
转换成：`扫描机-条形码扫描`
 */
let getGoodsTypeFullName=(goodsType)=> {
    let fullName = goodsType.name;
    let parent = goodsType.parent;
    while (parent) {
        fullName = parent.name + " - " + fullName;
        parent = parent.parent;
    }
    return fullName;
}

/**
* 商店类型编码，驼峰式
* 直营：direct
* 联营：join
* 加盟：franchise
*/
let goodsStoreTypeCodeMap = {
    direct: "直营",
    join: "联营",
    franchise: "加盟"
}

let goodsStoreTypeCodeList = [
    { code: "direct", name: "直营" },
    { code: "join", name: "联营" },
    { code: "franchise", name: "加盟" }
]

let getGoodsStoreTypeCodeList=()=>{
    return goodsStoreTypeCodeList;
}

let getNameByGoodsStoreTypeCode=(code)=>{
    return goodsStoreTypeCodeMap[code];
}

/**
 * 采购单状态
 * 草稿：draft
 * 已采购：purchased
 * 已撤销：revoked
 */
let purchaseOrderStatusMap = {
    draft: "草稿",
    purchased: "已采购",
    revoked: "已撤销"
}

let purchaseOrderStatusList = [
    { code: "draft", name: "草稿" },
    { code: "purchased", name: "已采购" },
    { code: "revoked", name: "已撤销" }
]

let getPurchaseOrderStatusList=()=>{
    return purchaseOrderStatusList;
}

let getNameByPurchaseOrderStatusCode=(code)=>{
    return purchaseOrderStatusMap[code];
}

export default {
    getGoodsTypeFullName,
    getGoodsStoreTypeCodeList,
    getNameByGoodsStoreTypeCode,
    getPurchaseOrderStatusList,
    getNameByPurchaseOrderStatusCode
}

